package org.example;

import java.sql.Connection;
import java.time.LocalDate;
import java.util.List;

public class Main {
    public static void main(String[] args) {

        Connection con = DBUtils.connectToDb();
        CRUDUtils.createTable(con, "Cards");

        Card c1 = new Card("1234 5678 1234 5678", "MIKE", LocalDate.of(2024,07,01), "987", "Mir", false);
        Card c2 = new Card("1234 9876 1234 9876", "VOVA", LocalDate.of(2026,12,01), "123", "Mir", false);
        Card c3 = new Card("2222 9876 2222 9876", "TTTT", LocalDate.of(2025,10,01), "456", "Mir", true);

        CRUDUtils.addCard(c1);
        CRUDUtils.addCard(c2);
        CRUDUtils.addCard(c3);

        CRUDUtils.updateCard(2, "1111 2222 3333 4444");
        CRUDUtils.deleteCard(3);
        List<Card> cardList = CRUDUtils.readCards("SELECT * FROM Cards");
        for (Card item: cardList) {
            System.out.println(item.toString());
        }
    }
}